var express = require('express');
var router = express.Router();
const query = require('../mysql');

/* post login listing. */
router.post('/', async function (req, res, next) {
	let user = req.body,
		sqlStr = 'select * from user where username = ? and password = ?';
	let result = await query(sqlStr, sqlArr);

	res.send('contest');
});

router.get('/category', async function (req, res, next) {
	let sqlStr = 'select category from contest_category ',
		sqlArr = [];
	let result = await query(sqlStr);
	if (result.length != 0) {
		res.send({
			status: 200,
			message: '获取竞赛信息成功',
			result,
		});
	} else {
		res.send({ status: 404, message: '获取竞赛信息失败' });
	}
});

module.exports = router;
